/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.liferay.model.impl;

import com.liferay.model.Student;
import com.liferay.model.StudentModel;
import com.liferay.model.StudentSoap;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * The base model implementation for the Student service. Represents a row in the &quot;student&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.liferay.model.StudentModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link StudentImpl}.
 * </p>
 *
 * @author JavaBoss
 * @see StudentImpl
 * @see com.liferay.model.Student
 * @see com.liferay.model.StudentModel
 * @generated
 */
@JSON(strict = true)
public class StudentModelImpl extends BaseModelImpl<Student>
	implements StudentModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a student model instance should use the {@link com.liferay.model.Student} interface instead.
	 */
	public static final String TABLE_NAME = "student";
	public static final Object[][] TABLE_COLUMNS = {
			{ "uuid_", Types.VARCHAR },
			{ "studentId", Types.BIGINT },
			{ "firstName", Types.VARCHAR },
			{ "lastName", Types.VARCHAR },
			{ "studentAge", Types.INTEGER },
			{ "studentGender", Types.INTEGER },
			{ "studentAddress", Types.VARCHAR },
			{ "hobies", Types.VARCHAR },
			{ "phoneNo", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table student (uuid_ VARCHAR(75) null,studentId LONG not null primary key,firstName VARCHAR(75) null,lastName VARCHAR(75) null,studentAge INTEGER,studentGender INTEGER,studentAddress VARCHAR(75) null,hobies VARCHAR(75) null,phoneNo LONG)";
	public static final String TABLE_SQL_DROP = "drop table student";
	public static final String ORDER_BY_JPQL = " ORDER BY student.studentId ASC";
	public static final String ORDER_BY_SQL = " ORDER BY student.studentId ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.liferay.model.Student"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.liferay.model.Student"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.liferay.model.Student"),
			true);
	public static long FIRSTNAME_COLUMN_BITMASK = 1L;
	public static long STUDENTGENDER_COLUMN_BITMASK = 2L;
	public static long UUID_COLUMN_BITMASK = 4L;
	public static long STUDENTID_COLUMN_BITMASK = 8L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static Student toModel(StudentSoap soapModel) {
		if (soapModel == null) {
			return null;
		}

		Student model = new StudentImpl();

		model.setUuid(soapModel.getUuid());
		model.setStudentId(soapModel.getStudentId());
		model.setFirstName(soapModel.getFirstName());
		model.setLastName(soapModel.getLastName());
		model.setStudentAge(soapModel.getStudentAge());
		model.setStudentGender(soapModel.getStudentGender());
		model.setStudentAddress(soapModel.getStudentAddress());
		model.setHobies(soapModel.getHobies());
		model.setPhoneNo(soapModel.getPhoneNo());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<Student> toModels(StudentSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<Student> models = new ArrayList<Student>(soapModels.length);

		for (StudentSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.liferay.model.Student"));

	public StudentModelImpl() {
	}

	@Override
	public long getPrimaryKey() {
		return _studentId;
	}

	@Override
	public void setPrimaryKey(long primaryKey) {
		setStudentId(primaryKey);
	}

	@Override
	public Serializable getPrimaryKeyObj() {
		return _studentId;
	}

	@Override
	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Class<?> getModelClass() {
		return Student.class;
	}

	@Override
	public String getModelClassName() {
		return Student.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("uuid", getUuid());
		attributes.put("studentId", getStudentId());
		attributes.put("firstName", getFirstName());
		attributes.put("lastName", getLastName());
		attributes.put("studentAge", getStudentAge());
		attributes.put("studentGender", getStudentGender());
		attributes.put("studentAddress", getStudentAddress());
		attributes.put("hobies", getHobies());
		attributes.put("phoneNo", getPhoneNo());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		String uuid = (String)attributes.get("uuid");

		if (uuid != null) {
			setUuid(uuid);
		}

		Long studentId = (Long)attributes.get("studentId");

		if (studentId != null) {
			setStudentId(studentId);
		}

		String firstName = (String)attributes.get("firstName");

		if (firstName != null) {
			setFirstName(firstName);
		}

		String lastName = (String)attributes.get("lastName");

		if (lastName != null) {
			setLastName(lastName);
		}

		Integer studentAge = (Integer)attributes.get("studentAge");

		if (studentAge != null) {
			setStudentAge(studentAge);
		}

		Integer studentGender = (Integer)attributes.get("studentGender");

		if (studentGender != null) {
			setStudentGender(studentGender);
		}

		String studentAddress = (String)attributes.get("studentAddress");

		if (studentAddress != null) {
			setStudentAddress(studentAddress);
		}

		String hobies = (String)attributes.get("hobies");

		if (hobies != null) {
			setHobies(hobies);
		}

		Long phoneNo = (Long)attributes.get("phoneNo");

		if (phoneNo != null) {
			setPhoneNo(phoneNo);
		}
	}

	@JSON
	@Override
	public String getUuid() {
		if (_uuid == null) {
			return StringPool.BLANK;
		}
		else {
			return _uuid;
		}
	}

	@Override
	public void setUuid(String uuid) {
		if (_originalUuid == null) {
			_originalUuid = _uuid;
		}

		_uuid = uuid;
	}

	public String getOriginalUuid() {
		return GetterUtil.getString(_originalUuid);
	}

	@JSON
	@Override
	public long getStudentId() {
		return _studentId;
	}

	@Override
	public void setStudentId(long studentId) {
		_columnBitmask = -1L;

		_studentId = studentId;
	}

	@JSON
	@Override
	public String getFirstName() {
		if (_firstName == null) {
			return StringPool.BLANK;
		}
		else {
			return _firstName;
		}
	}

	@Override
	public void setFirstName(String firstName) {
		_columnBitmask |= FIRSTNAME_COLUMN_BITMASK;

		if (_originalFirstName == null) {
			_originalFirstName = _firstName;
		}

		_firstName = firstName;
	}

	public String getOriginalFirstName() {
		return GetterUtil.getString(_originalFirstName);
	}

	@JSON
	@Override
	public String getLastName() {
		if (_lastName == null) {
			return StringPool.BLANK;
		}
		else {
			return _lastName;
		}
	}

	@Override
	public void setLastName(String lastName) {
		_lastName = lastName;
	}

	@JSON
	@Override
	public int getStudentAge() {
		return _studentAge;
	}

	@Override
	public void setStudentAge(int studentAge) {
		_studentAge = studentAge;
	}

	@JSON
	@Override
	public int getStudentGender() {
		return _studentGender;
	}

	@Override
	public void setStudentGender(int studentGender) {
		_columnBitmask |= STUDENTGENDER_COLUMN_BITMASK;

		if (!_setOriginalStudentGender) {
			_setOriginalStudentGender = true;

			_originalStudentGender = _studentGender;
		}

		_studentGender = studentGender;
	}

	public int getOriginalStudentGender() {
		return _originalStudentGender;
	}

	@JSON
	@Override
	public String getStudentAddress() {
		if (_studentAddress == null) {
			return StringPool.BLANK;
		}
		else {
			return _studentAddress;
		}
	}

	@Override
	public void setStudentAddress(String studentAddress) {
		_studentAddress = studentAddress;
	}

	@JSON
	@Override
	public String getHobies() {
		if (_hobies == null) {
			return StringPool.BLANK;
		}
		else {
			return _hobies;
		}
	}

	@Override
	public void setHobies(String hobies) {
		_hobies = hobies;
	}

	@JSON
	@Override
	public long getPhoneNo() {
		return _phoneNo;
	}

	@Override
	public void setPhoneNo(long phoneNo) {
		_phoneNo = phoneNo;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			Student.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public Student toEscapedModel() {
		if (_escapedModel == null) {
			_escapedModel = (Student)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
		}

		return _escapedModel;
	}

	@Override
	public Object clone() {
		StudentImpl studentImpl = new StudentImpl();

		studentImpl.setUuid(getUuid());
		studentImpl.setStudentId(getStudentId());
		studentImpl.setFirstName(getFirstName());
		studentImpl.setLastName(getLastName());
		studentImpl.setStudentAge(getStudentAge());
		studentImpl.setStudentGender(getStudentGender());
		studentImpl.setStudentAddress(getStudentAddress());
		studentImpl.setHobies(getHobies());
		studentImpl.setPhoneNo(getPhoneNo());

		studentImpl.resetOriginalValues();

		return studentImpl;
	}

	@Override
	public int compareTo(Student student) {
		int value = 0;

		if (getStudentId() < student.getStudentId()) {
			value = -1;
		}
		else if (getStudentId() > student.getStudentId()) {
			value = 1;
		}
		else {
			value = 0;
		}

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof Student)) {
			return false;
		}

		Student student = (Student)obj;

		long primaryKey = student.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		StudentModelImpl studentModelImpl = this;

		studentModelImpl._originalUuid = studentModelImpl._uuid;

		studentModelImpl._originalFirstName = studentModelImpl._firstName;

		studentModelImpl._originalStudentGender = studentModelImpl._studentGender;

		studentModelImpl._setOriginalStudentGender = false;

		studentModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<Student> toCacheModel() {
		StudentCacheModel studentCacheModel = new StudentCacheModel();

		studentCacheModel.uuid = getUuid();

		String uuid = studentCacheModel.uuid;

		if ((uuid != null) && (uuid.length() == 0)) {
			studentCacheModel.uuid = null;
		}

		studentCacheModel.studentId = getStudentId();

		studentCacheModel.firstName = getFirstName();

		String firstName = studentCacheModel.firstName;

		if ((firstName != null) && (firstName.length() == 0)) {
			studentCacheModel.firstName = null;
		}

		studentCacheModel.lastName = getLastName();

		String lastName = studentCacheModel.lastName;

		if ((lastName != null) && (lastName.length() == 0)) {
			studentCacheModel.lastName = null;
		}

		studentCacheModel.studentAge = getStudentAge();

		studentCacheModel.studentGender = getStudentGender();

		studentCacheModel.studentAddress = getStudentAddress();

		String studentAddress = studentCacheModel.studentAddress;

		if ((studentAddress != null) && (studentAddress.length() == 0)) {
			studentCacheModel.studentAddress = null;
		}

		studentCacheModel.hobies = getHobies();

		String hobies = studentCacheModel.hobies;

		if ((hobies != null) && (hobies.length() == 0)) {
			studentCacheModel.hobies = null;
		}

		studentCacheModel.phoneNo = getPhoneNo();

		return studentCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(19);

		sb.append("{uuid=");
		sb.append(getUuid());
		sb.append(", studentId=");
		sb.append(getStudentId());
		sb.append(", firstName=");
		sb.append(getFirstName());
		sb.append(", lastName=");
		sb.append(getLastName());
		sb.append(", studentAge=");
		sb.append(getStudentAge());
		sb.append(", studentGender=");
		sb.append(getStudentGender());
		sb.append(", studentAddress=");
		sb.append(getStudentAddress());
		sb.append(", hobies=");
		sb.append(getHobies());
		sb.append(", phoneNo=");
		sb.append(getPhoneNo());
		sb.append("}");

		return sb.toString();
	}

	@Override
	public String toXmlString() {
		StringBundler sb = new StringBundler(31);

		sb.append("<model><model-name>");
		sb.append("com.liferay.model.Student");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>uuid</column-name><column-value><![CDATA[");
		sb.append(getUuid());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>studentId</column-name><column-value><![CDATA[");
		sb.append(getStudentId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>firstName</column-name><column-value><![CDATA[");
		sb.append(getFirstName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>lastName</column-name><column-value><![CDATA[");
		sb.append(getLastName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>studentAge</column-name><column-value><![CDATA[");
		sb.append(getStudentAge());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>studentGender</column-name><column-value><![CDATA[");
		sb.append(getStudentGender());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>studentAddress</column-name><column-value><![CDATA[");
		sb.append(getStudentAddress());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>hobies</column-name><column-value><![CDATA[");
		sb.append(getHobies());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>phoneNo</column-name><column-value><![CDATA[");
		sb.append(getPhoneNo());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = Student.class.getClassLoader();
	private static Class<?>[] _escapedModelInterfaces = new Class[] {
			Student.class
		};
	private String _uuid;
	private String _originalUuid;
	private long _studentId;
	private String _firstName;
	private String _originalFirstName;
	private String _lastName;
	private int _studentAge;
	private int _studentGender;
	private int _originalStudentGender;
	private boolean _setOriginalStudentGender;
	private String _studentAddress;
	private String _hobies;
	private long _phoneNo;
	private long _columnBitmask;
	private Student _escapedModel;
}